﻿namespace Cos.Module.CMS.NHibernate
{
    using System;

    using Cos.Core.Model.Common;
    using Cos.Core.Model.Content;
    using Cos.Core.NHibernate;
    using Cos.Module.CMS.Data;

    using global::NHibernate;

    /// <summary>
    /// Menu repository.
    /// </summary>
    public class MenuRepository : RepositoryBase, IMenuRepository
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuRepository"/> class.
        /// </summary>
        /// <param name="sessionFactory">The session factory.</param>
        public MenuRepository(ISessionFactory sessionFactory) 
            : base(sessionFactory)
        {
        }


        /// <summary>
        /// Get the menu
        /// </summary>
        /// <param name="name">
        /// The name of the menu.
        /// </param>
        /// <param name="culture">
        /// The culture culture of the page.
        /// </param>
        /// <param name="isLiveMode">
        /// The  live mode is true if the user is viewing the site in live mode.
        /// </param>
        /// <returns>
        /// The root menu and the list of sub page and throws UnknownMenuException if the menu doesn't exist
        /// </returns>
        public Menu GetMenu(string name, Culture culture, bool isLiveMode)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Determines whether [is page visible] [the specified page].
        /// </summary>
        /// <param name="page">The page object.</param>
        /// <param name="isLiveMode">if set to <c>true</c> [is live mode].</param>
        /// <returns>
        ///   <c>true</c> if [is page visible] [the specified page]; otherwise, <c>false</c>.
        /// </returns>
        private bool IsPageVisible(Page page, bool isLiveMode)
        {
            if (page == null)
            {
                return false;
            }

            return page.IsVisible(isLiveMode);
        }
    }
}
